package com.lagou.utils;

import com.alibaba.druid.pool.DruidDataSource;
import com.alibaba.druid.pool.DruidPooledConnection;

import java.sql.SQLException;


public class DruidUtils {

    private static DruidDataSource druidDataSource = new DruidDataSource();

    static {
        druidDataSource.setDriverClassName("com.mysql.jdbc.Driver");
        druidDataSource.setDbType("com.alibaba.druid.pool.DruidDataSource");
        druidDataSource.setUrl("jdbc:mysql://192.168.80.11:3306/zdy_mybatis");
        druidDataSource.setUsername("root");
        druidDataSource.setPassword("root");
    }


    private DruidUtils() {
    }

    public static DruidDataSource getInstance() {
        return druidDataSource;
    }

    public static void main(String[] args) {
        try {
            DruidPooledConnection connection = DruidUtils.getInstance().getConnection();
            System.out.println(connection);
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
    }

}
